<?php
	$css_list[0]['url'] = './tpl/css/article.css';
?>
<!--{template inc/header_n}-->

<div class="main_warp">
    <div class="inventory">
        <!--{template inc/list/list_menu}-->

        <div class="i_righter">
            <p>
                当前位置：{$pl['tip']}[<?php echo date('Y-m-d', $pl['dateline']); ?>{if $pl['ampm']}下午{else}中午{/if}]
            </p>
            <div class="cart" style="width:100%;">
                <table class="i_tb">
                <!--{loop $pitems $k $v}-->
                    <tr>
                        <td class="j_tt" style="padding:10px 5px;"><label>
                        {if $v['isdir'] || $v['type'] == 'product'}
                        {$v['name']}
                        {else}
                        <a style="color:blue;" href="/list.php?action=plan&op=showitem&itemid={$v['item_id']}">{$v['name']}</a>
                        {if !empty($v['shopname'])}
                        [已绑定{$v['shopname']}]
                        {if $v['isstop']}
                        [<span style="color:red;">交易停止 退款成功 请到<a href="/shareinfo.php?action=withdraw">余额</a>里提现</span>]
                        {elseif $v['unpay']}
                        [<span style="color:red;">商家审核退款中…</span>]
                        {/if}
                        {/if}
                        {/if}
                        </label></td>
                        <td>{if !$v['isdir']}<span id="p_{$v['item_id']}">{if $v['flag']}已完成{else}未完成{/if}</span>{/if}</td>
                        <td>
                        {if !$v['isdir']}
                            {if $v['type'] == 'product' && !$v['flag']}
                            <input type="button" style="padding:2px 6px;" class="green_button" value="完成" onclick="comp({$v['item_id']}, this)"/>
                            {else}
                            -
                            {/if}
                        {/if}
                        </td>
                    </tr>
                    <!--{if $v['isdir']}-->
                    <tr><td colspan="3">
                        <table class="i_tb" style="margin:0 10px;width:90%;">
                            <!--{loop $v['children'] $k1 $v1}-->
                            <tr style="border:1px solid #CCC;">
                                <td>
                                {if $v1['type'] == 'product'}
                                {$v1['name']}
                                {else}
                                <a style="color:blue;" href="/list.php?action=plan&op=showitem&itemid={$v1['item_id']}">{$v1['name']}</a>
                                {/if}
                                </td>
                                <td><span id="p_{$v1['item_id']}">{if $v1['flag']}已完成{else}未完成{/if}</span></td>
                                <td>
                                {if $v1['type'] == 'product' && !$v1['flag']}
                                <input type="button" style="padding:2px 6px;" class="green_button" value="完成" onclick="comp({$v1['item_id']}, this)"/>
                                {else}
                                -
                                {/if}
                                </td>
                            </tr>
                            <!--{/loop}-->
                        </table>
                    </td></tr>
                    <!--{/if}-->
                <!--{/loop}-->
                </table>
            </div>
            <br/>
        </div>
        <br class="g_clear" />
</div>



<!--{template inc/footer}-->
<script language="javascript" type="text/javascript" src="/public/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="/public/js/jquery.form.min.js"></script>
<script type="text/javascript">
function sel(pid, b) {
    $('input[type=checkbox][group=g-'+pid+']').attr('checked', b);
}

$('#myform').ajaxForm(function(s) {
	if(s == 'tip empty') {
	    alert('进度表名称不能为空！');
	} else if(s == 'dateline empty') {
	    alert('时间不能为空！');
	} else if(s == 'ids empty') {
	    alert('请至少选择一个未完成项！');
	} else if(s == 'ok') {
	    location.href = '/list.php?action=plan';
	} else {
	    alert('未知错误！');
	}
});

function comp(itemid, obj) {
    $.post('/list.php?action=plan', {itemid : itemid, docomp : 1}, function(s) {
        if(s == '1') {
            $(obj).hide();
            $('#p_'+itemid).html('已完成');
        }
    });
}
</script>